﻿using Spectre.Console;

namespace ConsoleToolApp;

public class MainOperations
{
    public static void Run(bool isYear, bool isMonth, bool isWeek, bool isDay)
    {

        var date = DateTime.Now;


        if (isYear)
        {
            var percentageOfYear = ProgressHelper.YearProgress(date);

            AnsiConsole.Progress()
                .Start(ctx =>
                {
                    var task = ctx.AddTask("[green]Year Progress：[/]", maxValue: 100.0);
                    task.Increment(percentageOfYear.yearProgress);

                    AnsiConsole.MarkupLine($"[blue]Today is the {percentageOfYear.days}th day of the year.[/]");
                });
        }


        if (isMonth)
        {
            var monthProgress = ProgressHelper.MonthProgress(date);

            AnsiConsole.Progress()
                .Start(ctx =>
                {
                    var task = ctx.AddTask("[green]Month Progress：[/]");
                    task.Increment(monthProgress.monthProgress);

                    AnsiConsole.MarkupLine($"[blue]Today is the {monthProgress.days}th day of the month.[/]");
                });
        }


        if (isWeek)
        {
            var progress = ProgressHelper.WeekProgress(date);

            AnsiConsole.Progress()
                .Start(ctx =>
                {
                    var task = ctx.AddTask("[green]Week Progress：[/]");
                    task.Increment(progress.weekProgress);

                    AnsiConsole.MarkupLine($"[blue]Today is the {progress.days}th day of the week.[/]");
                });
        }


        if (isDay)
        {
            var progress = ProgressHelper.DayProgress(date);

            AnsiConsole.Progress()
                .Start(ctx =>
                {
                    var task = ctx.AddTask("[green]Day Progress：[/]");
                    task.Increment(progress.dayProgress);

                    AnsiConsole.MarkupLine($"[blue]现在: {progress.time:hh\\:mm}[/]");
                });
        }


    }
}